/*UR+dS5jSr8CsJCizbF2yPKsOabnCnM1iY5wL6+obS2OO5XhiP0KaANrOLP8eH1t3*/
/*
 * @Author: xiahui
 * @PageInfo: 变更
 * @Date: 2019-01-21 09:37:36
 * @Last Modified by: zhr
 * @Last Modified time: 2020-09-23 11:16:23
 */
import { UISTATUS, URL, AREA, FIELDS } from '../../constance';
import { ajax } from 'nc-lightapp-front';
import { buttonControl } from '../viewControl/buttonControl';
import { addRowForModify } from '../../utils/cardPageUtil';
import { getLangByResId } from '../../../../../scmpub/scmpub/pub/tool/multiLangUtil';
import { showWarningInfo } from '../../../../../scmpub/scmpub/pub/tool/messageUtil';

export default function(props, pk) {
	if (!props.form.getFormItemsValue(AREA.cardFormId, FIELDS.bshowlatest).value) {
		showWarningInfo(null, getLangByResId(this, '4004PURDAILY-000022')); /* 国际化处理： 合同不是最新版本，不允许变更*/
	}
	//增加数据权限校验
	ajax({
		url: URL.edit,
		data: pk ? pk : props.form.getFormItemsValue(AREA.cardFormId, FIELDS.pk_ct_pu).value,
		success: (res) => {
			if (res.success) {
				props.setUrlParam({ status: UISTATUS.modify });
				props.cardTable.selectAllRows(AREA.cardTableId, false); // 取消浏览态表体勾选
				buttonControl.call(this, props);
				addRowForModify.call(this, props);

				//测试让合同变更时，表体的付款协议页签
				props.cardTable.setStatus(AREA.cardPayId, UISTATUS.browse);
			}
		}
	});
}

/*UR+dS5jSr8CsJCizbF2yPKsOabnCnM1iY5wL6+obS2OO5XhiP0KaANrOLP8eH1t3*/